Re: [SQL] Relating 1 table to another. - Mailing list pgsql-sql

From Herouth Maoz
Subject Re: [SQL] Relating 1 table to another.
Date
Msg-id l03130303b34debfbb5b1@[147.233.159.109]
Whole thread Raw
In response to Re: [SQL] Relating 1 table to another.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
At 19:47 +0300 on 25/04/1999, Tom Lane wrote:


>
> This is where you need table aliases (AS clauses).  You do it like this:
>
> select project.id, project.name, p1.name, p2.name
> from project, people as p1, people as p2 where
> project.mainpersonid = p1.id and project.standbypersonid = p2.id;

No, AS is for field aliasing, not table aliasing.

The proper syntax is

SELECT project.id, project.name, p1.name, p2.name
FROM project, people p1, people p2
WHERE project.mainpersonid = p1.id AND project.standbypersonid = p2.id;

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




pgsql-sql by date:

Previous
From: Herouth Maoz
Date:
Subject: Re: [SQL] Finding the "most recent" rows
Next
From: José Soares
Date:
Subject: Re: [SQL] LIMIT